#ifndef _WIFIINO_FLASH_H_
#define _WIFIINO_FLASH_H_
#include "esp_err.h"
#include "esp_system.h"
#include "nvs_flash.h"
#include "esp_log.h"
#include "Datapara.h"


extern char  SSID_BUFF[];
extern char  PASSWORD_BUFF[];
extern char TrashCAN_Building[];
extern char TrashCAN_Floor[];
extern char TrashCAN_Room[];
extern char TrashCAN_RoomArea[];
extern char TrashCAN_Classification[];
#define NVS_WiFiInoCfgStatus_NAMESPACE "CfgStatus"  //wifi状态命令空间
#define NVS_OTACfgStatus_NAMESPACE "OTAStatus"        //ota状态命令空间
#define NVS_WiFi_Ino_NAMESPACE  "WiFi_Ino"        //namespace最长15字节   用于存储wifi相关信息的命名空间
#define NVS_Box_Ino_NAMESPACE  "CAN_Ino"      //namespace最长15字节  用于存储垃圾桶相关信息的命名空间
#define NVS_DEV_Id_NAMESPACE  "DEV_ID"

#define NVS_WiFiInoCfgStatus   "WifiStatus"            //WiFi名称键名
#define NVS_OTACfgStatus       "otaStatus"            //ota状态键名
#define NVS_SSID_KEY           "SSID"            //WiFi名称键名
#define NVS_PASSWORD_KEY       "PASSWORD"        //WiFi密码键名
#define NVS_DEV_ID_KEY          "device_id"      //设备Id
#define NVS_BUILDING_KEY       "BUILDING"        //楼栋号键名
#define NVS_FLOOR_KEY          "FLOOR"           //楼层键名
#define NVS_ROOM_KEY           "ROOM"            //房间号键名
#define NVS_ROOM_POSTION_KEY   "ROOM_POSTION"    //房间位置键名
#define NVS_BOX_TYPE_KEY       "BOX_TYPE"        //垃圾桶类型键名


extern int8_t WiFiInoCfgStatus;
extern int8_t OTA_FINISH_OR_FAIL;
extern uint8_t *WiFiInoCfgStatusPoint;

typedef struct{
    char *  ssid;
    char *  password;
    char *sta_ip_addr;
}WiFiIno_Type_t;

extern WiFiIno_Type_t WiFiIno;

typedef struct{

  char device_id[16];
  int64_t Dev_id;
  int32_t building_id;
  int32_t floor_id;
  int32_t room_id;
  int32_t device_location_id;
  int32_t device_type_id;
  int32_t position_id;
  int dustbin_flag;

  int32_t battery_flag;
  // char distance[32];  //为了在云端显示保留小数点后两位的样式，这里定义为数组
  float distance;
    
}LocationBatIno_Type_t;

extern LocationBatIno_Type_t LocationBatIno;

extern void write_nvs_byte(const char* namespace, const char* key, int8_t VALUE);
extern void read_nvs_byte(const char* namespace,const char* key, int8_t *VALUE);
extern void Write_nvs_str(const char* namespace,const char* key,const char* value);
extern void Write_nvs_blob(const char* namespace,const char* key,uint8_t* value,size_t len);
extern void Read_nvs_str(const char* namespace,const char* key,char* value,int maxlen);
extern void Erase_nvs_key(const char* namespace,const char* key);
extern void Write_nvs_int(const char* namespace, const char* key, int32_t value);
extern void Read_nvs_int(const char* namespace,const char* key, int32_t* value);
void Read_nvs_int64(const char* namespace, const char* key, int64_t *value);
void Write_nvs_int64(const char* namespace, const char* key, int64_t value);
extern void GetWiFiInoFromNvs();




#endif